package org.xdq.yeild;

public class testYeild {
    public static void main(String[] args) {
        //new Thread(){};创建了一个thread类的匿名子类对象
        Thread t1 = new Thread("t1"){//第一种创建线程方法
            @Override
            public void run() {
                for (int i =0;i<1000;i++){
                    System.out.println(this.getName()+"'"+i);
                    Thread.yield();
                }
            }
        };

        Thread t2 = new Thread(() -> {//第一种创建线程方法
            for (int i =0;i<1000;i++){
                System.out.println(Thread.currentThread().getName()+"'"+i);
                Thread.yield();
            }
        },"t2");

        t2.start();
        t1.start();
    }
}
